package com.example.tnot.Teacher.CoursePart.CourseInternal.CourseDetailHome.Publish.Adapter;

import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.tnot.R;
import com.example.tnot.Teacher.CoursePart.CourseInternal.CourseDetailHome.Publish.ItemBean.ListCourse;

import java.util.List;

public class CourseListAdapter extends RecyclerView.Adapter<CourseListAdapter.ViewHolder> {
    private List<ListCourse> list;
    public CourseListAdapter(List<ListCourse> list) {
        this.list = list;
    }


    @NonNull
    @Override
    public CourseListAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = View.inflate(parent.getContext(), R.layout.item_rv_publish_home_course_itemlist, null);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull CourseListAdapter.ViewHolder holder, int position) {
        holder.iv_icon.setImageResource(list.get(position).getIv_icon());
        holder.tv_Time.setText(list.get(position).getIv_Time());
        holder.tv_title.setText(list.get(position).getTv_title());
        holder.tv_Teacher.setText(list.get(position).getIv_teacher());
    }

    @Override
    public int getItemCount() {
        return list.size();
    }
    public static class ViewHolder extends RecyclerView.ViewHolder {
        ImageView iv_icon;
        TextView tv_Time;
        TextView tv_title;
        TextView tv_Teacher;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            iv_icon = itemView.findViewById(R.id.iv_icon);
            tv_Time = itemView.findViewById(R.id.tv_time);
            tv_title = itemView.findViewById(R.id.tv_title);
            tv_Teacher = itemView.findViewById(R.id.tv_teacher);
        }


    }
}

